package com.huluobo.a2109mvpimdemo.conversation;

import com.huluobo.a2109mvpimdemo.base.BasePresenter;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMConversation;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by LC on 2023/11/24.
 */
public class ConversationPresenter extends BasePresenter<ConversationContract.View> implements ConversationContract.Presenter {
    @Override
    public void loadConversations() {
        Map<String, EMConversation> allConversations = EMClient.getInstance().chatManager().getAllConversations();
        List<EMConversation> conversations = new ArrayList<>(allConversations.values());
        if (conversations.size() == 0) {
            if (isAttach()) {
                getView().loadConversationsFailed("当前没有会话信息");
            }
        } else {
            if (isAttach()) {
                getView().loadConversationsSuccess(conversations);
            }
        }
    }
}
